package com.xy.biz.fd.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.fd.domain.req.documentShare.ListDocumentShareRequest;
import com.xy.biz.fd.domain.req.documentShare.SaveDocumentShareRequest;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.fd.domain.bo.DocumentShareBO;
import com.xy.biz.fd.domain.po.DocumentSharePO;
import com.xy.biz.fd.domain.query.DocumentShareQuery;
import com.xy.biz.fd.domain.resp.GetDocumentShareResponse;
//import com.xy.biz.fd.domain.req.SaveDocumentShareRequest;
//import com.xy.biz.fd.domain.req.ListDocumentShareRequest;

/**
 *
 *
 * @author wcs
 * @date 2021-2-8
 */
public class DocumentShareConverter {

	public static DocumentSharePO toPO(DocumentShareBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentSharePO(), true);
	}

	public static List<DocumentSharePO> toPO(Collection<DocumentShareBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentSharePO(), true);
	}

	public static DocumentShareBO fromPO(DocumentSharePO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentShareBO());
	}

	public static List<DocumentShareBO> fromPO(Collection<DocumentSharePO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentShareBO());
	}

	public static DocumentShareBO toBO(SaveDocumentShareRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentShareBO(), true);
	}

	public static List<DocumentShareBO> toBO(Collection<SaveDocumentShareRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentShareBO(), true);
	}

	public static GetDocumentShareResponse toResponse(DocumentShareBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetDocumentShareResponse());
	}

	public static List<GetDocumentShareResponse> toResponse(Collection<DocumentShareBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetDocumentShareResponse());
	}

	public static DocumentShareQuery toQuery(ListDocumentShareRequest source) {
		if(null == source) {
			return null;
		}
		DocumentShareQuery target = new DocumentShareQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
